package model.admin;

import java.sql.ResultSet;
import java.util.ArrayList;

import myutil.Connect;

import vo.mixed.ProfessorListVo;

public class ModifyProfessorMo {

	public Boolean addProfessorDetails(ProfessorListVo professor_details) {
		String query = "INSERT INTO college_staff (staff_name, designation,joining_date, phone_number, address_line, city, state, country, email_id, staff_type, role, status) VALUES " +
				"('"+professor_details.getStaff_name()+"', '" +
				"Professor', " +
				"now(), '', '', '', '', '', '', 2, '', '1'); ";
		String query1="INSERT INTO professor_work (professor_id, course_id, patent, research, project, start_date) VALUES " +
				"((select max(staff_id) professor_id from staff_id where staff_type=2)," +
				"(select course_id from course_details where course_name='"+professor_details.getCourse_name()+"') ,'" +
				professor_details.getPatent()+"', '" +
				professor_details.getResearch()+"', '" +
				professor_details.getProject()+"', '');";
		Connect c = new Connect();
		try {
			c.dml(query);
			c.dml(query1);			
			return true;
		} catch (Exception e) {
			// TODO: handle exception
			return false;
		}
	}

	public Boolean updateProfessorDetails(ProfessorListVo professor_details) {
		String  query="";
			query = "update college_staff " + "set staff_name		=	'"
				+ professor_details.getStaff_name() + "'"
				+ "  where staff_id		=	" + professor_details.getStaff_id()
				+ ";";
		Connect c = new Connect();
		try {
			c.dml(query);
			return true;
		} catch (Exception e) {
			// TODO: handle exception
			return false;
		}
	}
}
